<#--
parameters:
	id : string, the html element id binding to
	dataModel : string, the dataModel binding to (required)
	parentId : string, the parent dropdown id (optional)
	params: json object, other parameters (optional)
	
author: 叶志明
-->

<#-- the url to request dropdown data -->
<@s.url var="actionUrl" action="dropdown" namespace="/widgets"/>

<script>
	$(document).ready(function() {
	
		<#if parameters.selector?exists>
		var obj = $("${parameters.selector}");
		<#elseif parameters.elementId?exists>
		var element = document.getElementById("${parameters.elementId}");
		var obj = $(element);
		<#elseif parameters.id?exists>
		var obj = $("#${parameters.id}");
		</#if>
	
		obj.ajaxDropdown({
			url: "${actionUrl}",
			<#if parameters.parentId?exists>
			parentSelector: "#${parameters.parentId}",
			<#elseif parameters.parentSelector?exists>
			parentSelector: "${parameters.parentSelector}",
			</#if>
			<#if parameters.defaultOptionLabel?exists>
			defaultOptionLabel: "${parameters.defaultOptionLabel}",
			</#if>
			<#if parameters.defaultOptionValue?exists>
			defaultOptionValue: "${parameters.defaultOptionValue}",
			</#if>
			<#if parameters.showDefaultOption?exists>
			showDefaultOption: ${parameters.showDefaultOption},
			</#if>
			<#if parameters.defaultSelectedValue?exists>
			defaultSelectedValue: "${parameters.defaultSelectedValue}",
			</#if>
			reverse: ${parameters.reverse?default(false)?string},
			cache: ${parameters.cache?default(true)?string},
			params: {
				dataModel: '${parameters.dataModel}'
			}
		});
	}); // ready
</script>
<#--
params: {
	<#list parameters?keys as itemKey>
	${itemKey}: "${parameters[itemKey]}",
	</#list>
	dump_p: ''
}
-->